using System.ComponentModel.DataAnnotations;
using  System.Data.Entity.ModelConfiguration;
using SalesPages.DomainModel;
namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class SEORelatedLinkMap : EntityTypeConfiguration<SEORelatedLink>
    {
        public SEORelatedLinkMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.LinkUrl)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.LinkText)
                .IsRequired()
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("SEORelatedLink");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SEOHubContent_Id).HasColumnName("SEOHubContent_Id");
            this.Property(t => t.OrderNo).HasColumnName("OrderNo");
            this.Property(t => t.LinkUrl).HasColumnName("LinkUrl");
            this.Property(t => t.LinkText).HasColumnName("LinkText");

            // Relationships
            this.HasRequired(t => t.SEOHubContent)
                .WithMany(t => t.SEORelatedLinks)
                .HasForeignKey(d => d.SEOHubContent_Id);

        }
    }
}
